﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ThanhTu.GNC.Media.KQXS.DataAccess.DAL;
using ThanhTu.GNC.Media.KQXS.DataAccess.DO;

namespace GNCMedia.KQXS.Admin
{
    public partial class UpdatePassWord : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txt_UserUpdate.Text = Request.QueryString["UserName"];
            }
        }

        protected void btn_changePas(object sender, EventArgs e)
        {
            UsersDAL userDAL = new UsersDAL();
            UsersDO userDO = new UsersDO();
            userDO.Username = txt_UserUpdate.Text;
            userDO.Pass = txt_newpass.Text;
            string confirmPas = txt_Confirmnewpass.Text;
            if (confirmPas.Equals(txt_newpass.Text))
            {
                userDO.Fullname = userDAL.GetByUser(txt_UserUpdate.Text, txt_oldPass.Text).Fullname;
                int checkUpdate = userDAL.SaveUser(userDO);
                if (checkUpdate > 0)
                {
                    lBLtHONGBAO.ForeColor = System.Drawing.Color.Blue;
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "javascript:alert('Đổi Mật Khẩu Thành công ! ');", true);
                }
                else
                {
                    lBLtHONGBAO.ForeColor = System.Drawing.Color.Red;
                    lBLtHONGBAO.Text = "ERORR";
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "javascript:alert(' Xác Nhận Mật khẩu KHÔNG đúng ');", true);
            }
        }

     
    }
}